package com.lzh.seatrend.util.commonsbeanutils;

import org.apache.commons.beanutils.ConstructorUtils;
import org.junit.Test;

import java.lang.reflect.Constructor;

public class ConstructorUtilsTest {

    @Test
    public void test() throws Exception{
        // 1.第一种写法
        Constructor<UserInfo> constructor = ConstructorUtils.getAccessibleConstructor(UserInfo.class, new Class[]{
                String.class, String.class
        });
        System.out.println(constructor.newInstance("lzh","刘子昊"));
        // 2.第二种写法
        UserInfo userInfo = ConstructorUtils.invokeConstructor(UserInfo.class,new String[]{
                "lzh","刘子昊"
        });
        System.out.println(userInfo);
    }
}
